<!DOCTYPE html>
<html>
    <head>
        <link href="../css/style.css" rel="stylesheet">
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Fauna+One">
        <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
        <script type="text/javascript" src="../js/script.js"></script>
    </head>
    
    <body onload="fillTable(predictionData, 'predictionsTable', maxTableSize); setupSectionButtons(predictionData, maxTableSize, 'btn', 1)">
        <div class="navbar">
            <ul class="navbar">
                <li class="navbar" id="logo"><a href="https://github.com/bergmanlab/mcclintock" target="_blank" class="logo">McClintock</a></li>
                <li class="navbar"><a href="../summary.html" class="navbar">Summary</a></li>
                <li class="navbar"><a href="families.html" class="navbar">TE Families</a></li>
                <li class="navbar dropdown">
                    <a href="#" class="navbar dropdown">TE Detection Methods</a>
                    <div class="dropdown-content">
                        {% for m in methods %}
                            <a href="{{ m }}.html" class="dropdown-content">{{ m }}</a>
                        {% endfor %}
                    </div>
                </li>
            </ul> 
        </div>

        <div class="row">
            <div class="sidebar">
                <ul class="sidebar">
                    <li class="sidebar"><a href="#plot1Header" class="sidebar">Family Prediction Summary</a></li>
                    <li class="sidebar"><a href="#plot2Header" class="sidebar">Predictions Per Contig</a></li>
                    <li class="sidebar"><a href="#predictionHeader" class="sidebar">{{method}} Prediction</a></li>
                </ul>
            </div>
            <div class="main">
                <div class="pageHeader">
                    <p class="pageHeader">{{method}}</p>
                </div>
                <div class="spacer2"></div>
                <div class="sectionHeader">
                    <a href="../data/methods/{{ method }}/family_predictions.txt"  target="_blank"><div class="sectionHeaderRaw">Raw</div></a>
                    <div class="sectionHeaderName">Family Prediction Summary</div>
                    <div class="sectionHeaderHide" id="plot1Header" onclick="hide('plot1Div','plot1Header')">Hide</div>
                </div>
                <div id="plot1Div">
                    <div class="runinfo" id="teinfo">
                        <div id="tester" class="plot1" style="width:100%;height:{{family_plot_height}}px;"></div>
                    </div>
                </div>
                <div class="spacer2"></div>
                <div class="sectionHeader">
                    <a href="../data/methods/{{ method }}/contig_predictions.txt"  target="_blank"><div class="sectionHeaderRaw">Raw</div></a>
                    <div class="sectionHeaderName">Predictions Per Contig</div>
                    <div class="sectionHeaderHide" id="plot2Header" onclick="hide('plot2Div','plot2Header')">Hide</div>
                </div>
                <div id="plot2Div">
                    <div class="runinfo" id="teinfo">
                        <div id="tester" class="plot2" style="width:100%;height:{{chrom_plot_height}}px;"></div>
                    </div>
                </div>
                <div class="spacer2"></div>
                <div class="sectionHeader">
                    <a href="../data/methods/{{ method }}/all_predictions.txt"   target="_blank"><div class="sectionHeaderRaw">Raw</div></a>
                    <div class="sectionHeaderName">{{ method }} Predictions</div>
                    <div class="sectionHeaderHide" id="predictionHeader" onclick="hide('familyinfoDiv','predictionHeader')">Hide</div>
                </div>
                <div id="familyinfoDiv">
                    <div class="filter">
                        <input type="button" id="filterButton" class="filterButton" name="filterButton" value="Filter" onclick="predictionData = filterData(unmodifiedData,'predictionsTable',maxTableSize, 'btn', 'filterTable1','filterTable2','exactBox2','refBox','nonrefBox', false, 'filterOption', 2, '')">
                        <input type="text" class="filterTable" id="filterTable1" autocomplete="off" placeholder="">
                        <input type="button" id="filterOption" class="filterOption" name="filterOption" value="and" onclick="flipFilterOption('filterOption')">
                        <input type="text" class="filterTable" id="filterTable2" autocomplete="off" placeholder="">
                        <input type="checkbox" class="checkbox" id="exactBox2" name="exactBox2" autocomplete="off" onclick="predictionData = filterData(unmodifiedData,'predictionsTable',maxTableSize, 'btn', 'filterTable1','filterTable2','exactBox2','refBox','nonrefBox', false, 'filterOption', 2, '')">
                        <label for="exactBox2">Exact Match</label>
                        <input type="checkbox" class="checkbox" id="refBox" name="refBox" checked="checked" autocomplete="off" onclick="predictionData = filterData(unmodifiedData,'predictionsTable',maxTableSize, 'btn', 'filterTable1','filterTable2','exactBox2','refBox','nonrefBox', false, 'filterOption', 2, '')">
                        <label for="exactBox2">Reference</label>
                        <input type="checkbox" class="checkbox" id="nonrefBox" name="nonrefBox" checked="checked" autocomplete="off" onclick="predictionData = filterData(unmodifiedData,'predictionsTable',maxTableSize, 'btn', 'filterTable1','filterTable2','exactBox2','refBox','nonrefBox', false, 'filterOption', 2, '')">
                        <label for="exactBox2">Non-Reference</label>
                        
                    </div>
                    <div class="runinfo largeTable" id="predictions">
                        <table class="run-information" id="predictionsTable">
                            <tr>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 0, maxTableSize, 'btn')">Contig</th>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 1, maxTableSize, 'btn')">Family</th>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 2, maxTableSize, 'btn')">Type</th>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 3, maxTableSize, 'btn', numeric=true)">Start</th>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 4, maxTableSize, 'btn', numeric=true)">End</th>
                                <th class="header" onclick="predictionData = sortTableLarge(predictionData,'predictionsTable', 5, maxTableSize, 'btn')">Strand</th>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="pageChanger" id="pageChanger">
                    <button class="pageChanger currentPage" id="btn1" value="1" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn1', 'btn')">1</button>
                    <button class="hiddenRange" id="btnh1">...</button>
                    <button class="pageChanger" id="btn2" value="2" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn2', 'btn')">2</button>
                    <button class="pageChanger" id="btn3" value="3" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn3', 'btn')">3</button>
                    <button class="pageChanger" id="btn4" value="4" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn4', 'btn')">4</button>
                    <button class="pageChanger" id="btn5" value="5" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn5', 'btn')">5</button>
                    <button class="pageChanger" id="btn6" value="6" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn6', 'btn')">6</button>
                    <button class="hiddenRange" id="btnh2">...</button>
                    <button class="pageChanger" id="btn7" value="19" onclick="showSection(predictionData, 'predictionsTable', maxTableSize, 'btn7', 'btn')">19</button>
                    <button class="goSection" id="btnGo" value="" onclick="goToSection('btnInput', predictionData, 'predictionsTable', maxTableSize, 'btn')">&rsaquo;</button>
                    <input type="text" class="inputSection" id="btnInput" autocomplete="off" placeholder="">
                    
                </div>
                <div class="spacer2"></div>
            </div>
        </div>

        <!-- data for prediction table -->
        <script>
            var maxTableSize = 20;
            var predictionData = [
                ['Contig','Family','Type','Start','End','Strand'],
                {% for p in predictions %}
                    [ '{{ p.chrom }}', '{{ p.family }}', '{{ p.type }}', '{{ p.start }}', '{{ p.end }}', '{{ p.strand }}' ],
                {% endfor %}
            ];

            const unmodifiedData = [...predictionData];
        </script>


        <!-- plot 1: Family Summary -->
        <script>
            var trace1 = {
            x: [
                {% for count in reference_family_counts %}
                    {{count}},
                {% endfor %}
            ],
            y: [
                {% for family in families %}
                    '{{family}}',
                {% endfor %}
            ],
            name: 'Reference',
            orientation: 'h',
            marker: {
                color: 'rgba(25,25,25,0.6)',
                width: 1
            },
            type: 'bar'
            };

            var trace2 = {
            x: [
                {% for count in nonreference_family_counts %}
                    {{count}},
                {% endfor %}
            ],
            y: [
                {% for family in families %}
                    '{{family}}',
                {% endfor %}
            ],
            name: 'Non-Reference',
            orientation: 'h',
            type: 'bar',
            marker: {
                color: 'rgba(95,95,95,0.6)',
                width: 1
            }
            };

            var data = [trace1, trace2];

            var layout = {
            barmode: 'stack',
            showlegend: true,
            font: {size: 12},
            margin: {'t':50, 'b':10},
            xaxis: {automargin: true, side: 'top'},
            yaxis: {automargin: true}
            };

            var div = document.getElementsByClassName('plot1')[0];
            Plotly.newPlot(div, data, layout);
        </script>

        <!-- plot 2: Chromosome Summary -->
        <script>
            var trace1 = {
            x: [
                {% for counts in reference_chromosome_counts %}
                    {{ counts }},
                {% endfor %}
            ],
            y: [
                {% for chromosome in chromosomes %}
                    '{{ chromosome }}',
                {% endfor %}
            ],
            name: 'Reference',
            orientation: 'h',
            marker: {
                color: 'rgba(25,25,25,0.6)',
                width: 1
            },
            type: 'bar'
            };

            var trace2 = {
            x: [
                {% for counts in nonreference_chromosome_counts %}
                    {{ counts }},
                {% endfor %}
            ],
            y: [
                {% for chromosome in chromosomes %}
                    '{{ chromosome }}',
                {% endfor %}
            ],
            name: 'Non-Reference',
            orientation: 'h',
            type: 'bar',
            marker: {
                color: 'rgba(95,95,95,0.6)',
                width: 1
            }
            };

            var data = [trace1, trace2];

            var layout = {
            barmode: 'stack',
            showlegend: true,
            font: {size: 12},
            margin: {'t':50, 'b':10},
            xaxis: {automargin: true, side: 'top'},
            yaxis: {automargin: true}
            };

            var div = document.getElementsByClassName('plot2')[0];
            Plotly.newPlot(div, data, layout);
        </script>
    </body>

</html>